package com.ruoyi.fee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fee.domain.WStackTransferFeeRule;
import com.ruoyi.fee.service.IWStackTransferFeeRuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 倒垛费Controller
 * 
 * @author wzy
 * @date 2024-08-30 11:57:04
 */
@RestController
@RequestMapping("/fees/stacktransfer")
public class WStackTransferFeeRuleController extends BaseController
{
    @Autowired
    private IWStackTransferFeeRuleService wStackTransferFeeRuleService;

    /**
     * 查询倒垛费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:stacktransfer:list')")
    @GetMapping("/list")
    public TableDataInfo list(WStackTransferFeeRule wStackTransferFeeRule)
    {
        startPage();
        List<WStackTransferFeeRule> list = wStackTransferFeeRuleService.selectWStackTransferFeeRuleList(wStackTransferFeeRule);
        return getDataTable(list);
    }

    /**
     * 导出倒垛费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:stacktransfer:export')")
    @Log(title = "倒垛费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WStackTransferFeeRule wStackTransferFeeRule)
    {
        List<WStackTransferFeeRule> list = wStackTransferFeeRuleService.selectWStackTransferFeeRuleList(wStackTransferFeeRule);
        ExcelUtil<WStackTransferFeeRule> util = new ExcelUtil<WStackTransferFeeRule>(WStackTransferFeeRule.class);
        util.exportExcel(response, list, "倒垛费数据");
    }

    /**
     * 获取倒垛费详细信息
     */
    @PreAuthorize("@ss.hasPermi('fees:stacktransfer:query')")
    @GetMapping(value = "/{stackTransferFeeId}")
    public AjaxResult getInfo(@PathVariable("stackTransferFeeId") Long stackTransferFeeId)
    {
        return success(wStackTransferFeeRuleService.selectWStackTransferFeeRuleByStackTransferFeeId(stackTransferFeeId));
    }

    /**
     * 新增倒垛费
     */
    @PreAuthorize("@ss.hasPermi('fees:stacktransfer:add')")
    @Log(title = "倒垛费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WStackTransferFeeRule wStackTransferFeeRule)
    {
        wStackTransferFeeRule.setCreateBy(getNickName());
        return toAjax(wStackTransferFeeRuleService.insertWStackTransferFeeRule(wStackTransferFeeRule));
    }

    /**
     * 修改倒垛费
     */
    @PreAuthorize("@ss.hasPermi('fees:stacktransfer:edit')")
    @Log(title = "倒垛费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WStackTransferFeeRule wStackTransferFeeRule)
    {
        wStackTransferFeeRule.setUpdateBy(getNickName());
        return toAjax(wStackTransferFeeRuleService.updateWStackTransferFeeRule(wStackTransferFeeRule));
    }

    /**
     * 删除倒垛费
     */
    @PreAuthorize("@ss.hasPermi('fees:stacktransfer:remove')")
    @Log(title = "倒垛费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stackTransferFeeIds}")
    public AjaxResult remove(@PathVariable Long[] stackTransferFeeIds)
    {
        return toAjax(wStackTransferFeeRuleService.deleteWStackTransferFeeRuleByStackTransferFeeIds(stackTransferFeeIds));
    }
}
